import Vue from 'vue'
import VueRouter from 'vue-router'
import {GetToken} from '@/utils'

Vue.use(VueRouter)

const routes = [{
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/home'),
    children: [{
        path: '/',
        name: 'main',
        component: () => import('@/views/main')
      },
      {
        path: '/users',
        name: 'users',
        component: () => import('@/views/users'),
        meta: {
          title: '用户列表'
        }
      },
      {
        path: '/roles',
        name: 'roles',
        component: () => import('@/views/authority/roles'),
        meta: {
          title: '角色列表'
        }
      },
      {
        path: '/rights',
        name: 'rights',
        component: () => import('@/views/authority/rights'),
        meta: {
          title: '权限列表'
        }
      },
      {
        path: '/goods',
        name: 'goods',
        component: () => import('@/views/commodity/goods'),
        meta: {
          title: '商品列表'
        }
      },
      {
        path: '/goods/add',
        name: 'add',
        component: () => import('@/views/commodity/add'),
        meta: {
          title: '添加商品'
        }
      },
      {
        path: '/params',
        name: 'params',
        component: () => import('@/views/commodity/params'),
        meta: {
          title: '分类参数'
        }
      },
      {
        path: '/categories',
        name: 'categories',
        component: () => import('@/views/commodity/categories'),
        meta: {
          title: '商品分类'
        }
      },
      {
        path: '/orders',
        name: 'orders',
        component: () => import('@/views/orders/orders'),
        meta: {
          title: '订单列表'
        }
      },
      {
        path: '/reports',
        name: 'reports',
        component: () => import('@/views/information/reports'),
        meta: {
          title: '数据报表'
        }
      },
    ]
  },
  {
    path:'/',
    redirect:GetToken('redirectPath')?GetToken('redirectPath'):'/',
  }

]

const router = new VueRouter({
  routes
})

export default router